package com.body;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class message_control extends HttpServlet{
	private String mutex = "";          
	private String StrYes;
	private HttpSession session;  // session
	private PrintWriter out;     
	private String tousername="";
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		synchronized (mutex){
			session  = req.getSession();
			out = resp.getWriter();
			StrYes = (String )session.getAttribute("yes");
			
			resp.setHeader("Content-type", "text/html;charset=utf-8"); 
			resp.setCharacterEncoding("utf-8");
			resp.setCharacterEncoding("utf-8");
			
			if(!("yes".equals(StrYes))){
				out.print("<script>alert('Please login first!');</script>");
				out.print("<script  type='text/javascript'  >; window.location.href='login.jsp?from=1';  </script> ");
				return ;
			} else {
				resp.sendRedirect("message.jsp?findmessage=");
			}
		}
	}
	
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
}
